import {
  reqCategoryList,
  reqGetBannerList,
  reqGetFloorList
} from '../../api'
const state = {
  categoryList: [],
  bannerList: [],
  floorList: []
}
const mutations = {
  CATEGORYLIST(state, categoryList) {
    state.categoryList = categoryList
  },
  BANNERLIST(state, bannerList) {
    state.bannerList = bannerList
  },
  FLOORLIST(state, floorList) {
    state.floorList = floorList
  }
}
const actions = {
  // 通过API里面的接口函数调用，向服务器发送请求，获取服务器的数据
  async categoryList({
    commit
  }) {
    const result = await reqCategoryList()
    if (result.code == 200) {
      commit('CATEGORYLIST', result.data)
    }
  },
  // banner数据
  async getBannerList({
    commit
  }) {
    await reqGetBannerList().then((res) => {
      if (res.code == 200) {
        commit('BANNERLIST', res.data)

      }
    })
  },
  // floor数据
  async getFloorList({
    commit
  }) {
    await reqGetFloorList().then((res) => {
      if (res.code == 200) {
        commit('FLOORLIST', res.data)

      }
    })
  }
}
const getters = {}
export default {
  state,
  mutations,
  actions,
  getters
}